package tss;

import java.io.*;

/**
 * A Transport represents a specific way of communicating over a network
 * 
 * <p>It contains a network stack (of layers) that machines that it communicate
 * with are expected to also have
 * 
 * @author Klaus Marius Hansen, klaus.m.hansen@daimi.au.dk
 *
 */
public interface Transport {
	/**
	 * Set the properties of this transport. The properties
	 * of the contained layers are set with the same properties
	 * array
	 * 
	 * @param properties to set on the transport
	 */
	public void setProperties(String ... properties);
	
	/**
	 * Send a message using this transport

	 * @throws IOException
	 */
	public void send(Message message) throws IOException;
	
	/**
	 * Receive a message using this transport.
	 * Blocks the calling Thread until a message is actually
	 * received
	 * 
	 * @return the message received
	 */
	public Message receive();
	
	/**
	 * 
	 * @return The message most recently received from the network but
	 *         that has not yet be removed by calling Message.receive().
	 *         If there are no pending messages, null is returned
	 */
	public Message peek();
}
